﻿using ArtMath.Resource;
using System;
using System.Windows.Forms;

namespace ArtMath.Window
{
    public partial class ComponentsPickerWindow : Form
    {
        public ComponentsPickerWindow(ListViewItem[] items, int count, string desc, string[] colNames)
        {
            InitializeComponent();
            label1.Text = desc;
            lvComponents.Columns.Add(Resources.Translate("Name"));
            foreach (string item in colNames)
            {
                lvComponents.Columns.Add(item);
            }
            lvComponents.Items.AddRange(items);
            lvComponents.ItemChecked += (object sender, ItemCheckedEventArgs e) =>
            {
                btnOK.Enabled = lvComponents.CheckedItems.Count == count;
            };
        }

        private void cancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        private void ok_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }
        private void lvComponents_ItemActivate(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }
    }
}
